package demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import demo.model.User;

@Path("record")
public class LoginRecord extends Controller {
    public void index() {
        render("record.html");
    }

    public void list() {
        int page = getParaToInt("page");
        int limit = getParaToInt("limit");
        String userName = getPara("userName");
        //Page<User> userPage = User.dao.paginate(page,limit,"select * ", "from sys_log");
        Page<User> userPage = User.dao.template("getList2", new Kv().by("userName",userName)).paginate(page,limit);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code",0);
        jsonObject.put("msg","操作成功");
        jsonObject.put("count", userPage.getTotalRow());
        jsonObject.put("data", userPage.getList());
        renderJson(jsonObject);
    }
}
